Skip to content

fix(service): the request budget counts only what GitHub counts - #3946

Merged
dan-petty merged 2 commits into
mainfrom
fix/3939-request-budget-counts-github
Nov 7, 2026
Merged

dan-petty merged 2 commits into
mainfrom
fix/3939-request-budget-counts-github

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The Service request budget counted every request, so it counted the answers with status 304. GitHub does not count a 304 answer against its primary rate limit, and the budget protects that limit. In one hour, 880 of 2020 counted requests were 304 answers. The budget sat at its limit all day and delayed the rounds. A request now gives its place back when its answer is 304. A request with no answer stays in the budget. The metric devops_cli_github_requests_total still counts every request with its status. The alert RoadmapServiceGitHubRequestsHigh leaves out status 304, so it follows the budget. The budget value does not change.

Closes #3939

Change: openspec/changes/archive/2026-11-07-3939-request-budget-counts-github/
Elapsed: 3.83s

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/service The long-running devops Service and its lanes labels Nov 7, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Evidence

Before (Prometheus, 2026-11-07, one hour, job="roadmap-service"): 2020 requests. By status: 200 = 887, 304 = 880, none = 264. 304 is 43.6% of the total. In the last 12 hours the total was 1,800 to 1,970 an hour. By row, without 304: metrics 288, refine 286, other 236, implement 139, stage_ready 85, release_comments 46, stage 43, intake 16.

After (estimate): the budget counts about 2020 - 880 = 1140 requests an hour at the same load, 57% of the budget of 2000. The metric still shows 2020. Rounds that waited can run now, so the request rate can rise until it meets the budget again. A person must measure after the merge and the rollout: sum(increase(devops_cli_github_requests_total{job="roadmap-service", status!="304"}[1h])) and devops_cli_service_budget_spent_requests.

Sources (rule of the task, three largest by counted requests): metrics 288 (#3941), refine 286 (comment on #3866, which holds the cut of #3918), other 236 (#3942). No cut is in this pull request: each cut changes a job, and the budget no longer starves without it.

#3672 (an idle repository polls less often): this change does not make it unnecessary. Idle polls were mostly 304 answers, which no longer count, but they still use the Service, the network and the rate-limit headers, and the 200 answers of the row other stay. Re-read #3672 after the re-measure.

Status none: all 264 are GETs of the core resource. A gh command always has status none, so the metric cannot tell it from a lost connection, and a timed-out request may have reached GitHub. They stay in the budget.

Sources of the rule: GitHub docs, "Best practices for using the REST API", "Use conditional requests" (a 304 answer to an authorized conditional request does not count against the primary rate limit); "Rate limits for the REST API" (installation minimum 5,000 an hour).

Checks run

  • uv run devops ci fail-to-pass --base origin/main: 6 tests failed on the base, in tests/github/test_service_limits.py and tests/prometheus/test_k8s_monitoring_alerting.py. They pass on the branch.
  • flock ... uv run devops ci: exit 0 on the branch before the rebase. It printed "Tests took 6m 16s, over the 5m budget" (known, fix(ci): the pytest step of devops ci exceeds the 5-minute budget #3593); the slowest test is the promtool run of the alert rules, 108 s.
  • After the rebase onto origin/main: uv run devops ci test tests/github/test_service_limits.py passes (41 tests).

@dan-petty
dan-petty marked this pull request as ready for review November 7, 2026 06:21
@dan-petty
dan-petty merged commit b3f8793 into main Nov 7, 2026
24 checks passed
@dan-petty
dan-petty deleted the fix/3939-request-budget-counts-github branch November 7, 2026 11:47
dan-petty pushed a commit that referenced this pull request Nov 7, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.78.0](v0.77.2...v0.78.0)
(2026-11-07)


### Features

* **k8s:** add the Crawl4AI token to the cluster secrets
([#3937](#3937))
([5e6eb59](5e6eb59))
* **research:** list every pin of the project
([#3945](#3945))
([cb65daa](cb65daa)),
closes [#3896](#3896)


### Bug Fixes

* **roadmap:** a fix step edits only the paths the plan names
([#3944](#3944))
([7745fa8](7745fa8))
* **roadmap:** read only the marked code spans of a plan
([#3912](#3912))
([72c52c6](72c52c6))
* **service:** the request budget counts only what GitHub counts
([#3946](#3946))
([b3f8793](b3f8793))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/service The long-running devops Service and its lanes type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(service): the request budget counts only requests GitHub counts

1 participant